<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  
  <head>
    <title>药品添加</title>
    <jsp:include page="header.jsp"></jsp:include>
    <%-- <link rel="stylesheet" href="${pageContext.request.contextPath }/lib/kindeditor/themes/default/default.css" /> --%>
    <script charset="utf-8" src="${pageContext.request.contextPath }/lib/kindeditor/kindeditor-all.js"></script>
	<script charset="utf-8" src="${pageContext.request.contextPath }/lib/kindeditor/lang/zh-CN.js"></script>
    
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <style>
  	.my-upload {
  		display: block;
  		width: 100px;
  		height: 32px;
  		text-align: center;
  		margin-top: 10px;
  		background-color: red;
  		color:#ffffff;
  		line-height:32px;
  		font-size: 16px;
  	}
  </style>
  <body>
    <div class="x-body">
        <form class="layui-form" id="myForm" action="/admin/saveItem" method="post">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>药品名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="goodsName" name="goodsName" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" value="${item.goodsName}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>厂家
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="goodsPoint" name="goodsPoint" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" value="${item.goodsPoint}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>商品规格
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="goodsType" name="goodsType" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" value="${item.goodsType}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>图片
              </label>
              <div class="layui-input-inline">
              		<a class="my-upload" href="javascript:;" id="J_selectImage">上传图片</a>
                  <input type="hidden" id="goodsRemark" name="goodsRemark" autocomplete="off" class="layui-input" value="${item.goodsRemark}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>商品库存
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="goodsStorge" name="goodsStorge" required="" lay-verify="number"
                  autocomplete="off" class="layui-input" value="${item.goodsStorge}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>商品价格
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="goodsPrice" name="goodsPrice" required="" lay-verify="number"
                  autocomplete="off" class="layui-input" value="${item.goodsPrice}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>商品原价
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="goodsDecode" name="goodsDecode" required="" lay-verify="number"
                  autocomplete="off" class="layui-input" value="${item.goodsDecode}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>置顶商品
              </label>
              <div class="layui-input-inline">
              		 <input type="radio" name="goodsSell" value="1" title="是">
      				 <input type="radio" name="goodsSell" value="0" title="否" checked>
                  
              </div>
          </div>
          <div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
                  描述
              </label>
              <div class="layui-input-block">
                  <textarea placeholder="请输入内容" id="desc" name="goodsDetail" class="layui-textarea">
                  	${item.goodsDetail}
                  </textarea>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <input type="hidden" name="id" value="${item.id}">
             <button  class="layui-btn" lay-filter="add" id="my_add">
                  增加
              </button>
             
          </div>
      </form>
    </div>
    <script type="text/javascript">
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('#desc', {
        	themeType : 'simple',
            resizeType: 1,
            imageSizeLimit : '10MB',
        	cssPath : '${pageContext.request.contextPath }/lib/kindeditor/plugins/code/prettify.css',
			uploadJson : '${pageContext.request.contextPath }/admin/kindUpload',//标识处理图片的文件
			fileManagerJson :'${pageContext.request.contextPath }/admin/kindUpload',
			allowFileManager : true,//允许上传文件和图片
        });
        K('#J_selectImage').click(function() {
        	editor.loadPlugin('multiimage', function() {
    			editor.plugin.multiImageDialog({
    				clickFn : function(urlList) {
    					var div = K('#goodsRemark');
    					var str="";
    					div.val('');
    					K.each(urlList, function(i, data) {
    						//div.append('<img src="' + data.url + '">');
    						str+=data.url;
    						str+=",";
    					});
    					div.val(str);
    					layer.alert('上传文件成功!');
    					editor.hideDialog();
    				}
    			});
        	});
        });
    });
    $('#my_add').click(function(){
    	 var form =$('#myForm');
    	 var remark =$('#goodsRemark').val();
         var detail=editor.html();
         if(remark==''){
         	layer.alert('请上传图片!');
         }
         $('#desc').val(detail);
         var index = parent.layer.getFrameIndex(window.name);
         //关闭当前frame
         parent.layer.close(index);
         parent.location.reload();
         form.submit();
    });
	</script>
  </body>
</html>